<template>
	<view class="container">
		<view class="user-section" :style="{paddingTop: `calc(74rpx + ${safeArea.top}px)`}">
			<!-- <image class="bg" src="/static/image/topbg.jpg"></image> -->
			<view class="bg">
				<image class="bg-img" mode="aspectFit" src="https://yuyitang.oss-cn-shenzhen.aliyuncs.com/yytfile/upload/2022/07/27/6da58879-0f33-486f-aec4-3a453ccbd318.png"></image>
			</view>
			<view class="user-info-box">
				<view class="portrait-box">
					<image class="portrait" :src="userInfo.icon || '/static/missing-face.png'"></image>
				</view>	
				<template>
					<!-- <view class="icon-huiyuan" style="margin-right: 10rpx;">
						<image src="../../../static/image/huiyuan.png" style="width: 50rpx; height: 50rpx;"></image>
					</view>		 -->			
					<view class="user-right" v-if="hasLogin" @click="navTo('/pages/user/level')">
						<view class="user-name" v-if="userInfo.nickname != null">{{userInfo.nickname}}</view>
						<view class="user-name" v-else>{{userInfo.username == null?'':userInfo.username}}</view>
						<!-- <view class="" style="display: flex; flex-direction: row; margin-top: 10rpx;">
							<image src="../../../static/image/huiyuandengji.png" style="width: 30rpx; height: 30rpx;"></image>
							<view class="user-grade" v-if="empirical.name != null">
								{{empirical.name}}
							</view>
						</view> -->
						<view class="user-other">
							<view class="phone">{{userInfo.phone == null || userInfo.phone == ''?"":userInfo.phone}}</view>
							<view class="vip-label" v-if="userInfo.isVip == '1'" @click="goVipRenew">
								<image src="../../../static/image/mine/vip.png" mode="aspectFit" class="icon"></image>
								<view class="label">{{myVipInfo.name}}会员</view>
							</view>
						</view>
					</view>
					<view class="user-right" v-if="!hasLogin">
						<view style="color: #111111; font-size: 34rpx; font-weight: medium;">游客</view>
						<view class="login-box">
							<view class="b-btn" style="color: #7EAFA5;" @click="immediatelyLogin">立即登录</view>
						</view>
					</view>
				</template>	
				<!-- <view style="margin-left: 30rpx; height: 160rpx; display: flex; flex-direction: column; padding-top: 30rpx;">
									
					<view style="width: 180rpx; height: 20rpx;" v-if="hasLogin">
						<u-line-progress :percent="plan" height="20" active-color="#72EDE3" inactive-color="#A08EFF" :striped="true" :striped-active="true"></u-line-progress>
					</view>
				</view> -->
				<!-- <view class="customer-service" @click="customerService">
					<text class="iconfont yticon icon-kefu1"></text>
					<view class="customer-service-text">客服</view>
				</view> -->
			</view>
			
		</view>

		<view class="cover-container" :style="[{
				transform: coverTransform,
				transition: coverTransition
			}]" @touchstart="coverTouchstart" @touchmove="coverTouchmove" @touchend="coverTouchend">
			<!-- <image class="arc" src="/static/arc.png"></image> -->
			<navigator v-if="false" :url="userInfo.isVip == '1' ? `/pagesB/vip/topUp/mine` : `/pagesB/vip/topUp/index`" class="vip-box" hover-class="none-hover">
				<image mode="aspectFit" src="../../../static/image/mine/rogue.png" class="icon"></image>
				<view class="vip-tips">{{userInfo.isVip == '1' ? '查看年卡会员特权' : '开通年卡会员了解更多特权'}}</view>
				<view class="btn">
					<view class="tips">{{userInfo.isVip == '1' ? '去查看' : '去开通'}}</view>
					<u-icon name="arrow-right" color="#ffffff" size="20"></u-icon>
				</view>
			</navigator>
			
			<!-- 订单 -->
			<view class="order-section">
				<!-- <view class="order-item" @click="navTo('/pagesA/sys/user/order?type=')" hover-class="common-hover"
					:hover-stay-time="50">
					<text class="yticon icon-shouye"></text>
					<text>全部订单</text>
				</view> -->
				<view class="order-title">
					<view class="title">我的订单</view>
					<view class="order-arrow" @click="navTo('/pagesA/sys/user/order?type=')">
						<view class="order-tips">更多</view>
						<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
					</view>
				</view>
				<view class="order-list">
					<view v-if="false" class="order-item" hover-class="common-hover"
						:hover-stay-time="50" style="text-align: center;">
						<text class="yticon order-icon" style="display:flex;align-items:center;justify-content: center;">{{myNumber || 0}}</text>
						<!-- <image src="../../../static/image/mine/order-01.png" mode="aspectFit" class="order-icon"></image> -->
						<text class="order-title">年卡次数</text>
					</view>
					<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=1')" hover-class="common-hover"
						:hover-stay-time="50">
						<!-- <text class="yticon icon-daifukuan"></text> -->
						<uni-badge style="position: absolute; top: -10rpx; right: -20rpx;" type="error" v-if="toPayOrderCount>0" :text="toPayOrderCount+''"></uni-badge>
						<image src="../../../static/image/mine/order-01.png" mode="aspectFit" class="order-icon"></image>
						<text class="order-title">待付款</text>
					</view>
					<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=2')"
						hover-class="common-hover" :hover-stay-time="50">
						<!-- <text class="yticon icon-shouye"></text> -->
						<image src="../../../static/image/mine/order-02.png" mode="aspectFit" class="order-icon"></image>
						<text class="order-title">待发货</text>
					</view>
					<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=3')" hover-class="common-hover"
						:hover-stay-time="50">
						<!-- <text class="yticon icon-yishouhuo"></text> -->
						<uni-badge style="position: absolute; top: -10rpx; right: -20rpx;" type="error" v-if="toConfirmOrderCount>0" :text="toConfirmOrderCount+''"></uni-badge>
						<image src="../../../static/image/mine/order-03.png" mode="aspectFit" class="order-icon"></image>
						<text class="order-title">待收货</text>
					</view>
					<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=4')" hover-class="common-hover"
						:hover-stay-time="50">
						<!-- <text class="yticon icon-shouhoutuikuan"></text> -->
						<uni-badge style="position: absolute; top: -10rpx; right: -20rpx;" type="error" v-if="afterSaleCount>0" :text="afterSaleCount+''"></uni-badge>
						<image src="../../../static/image/mine/order-04.png" mode="aspectFit" class="order-icon"></image>
						<text class="order-title">已完成</text>
					</view>
				</view>
				
			</view>
			<!-- <view class="tj-sction">
				<view class="tj-item">
					<text class="num" @click="navTo('/pagesA/sys/user/balance')">{{myNumber||0}}</text>
					<text>可送次数</text>
				</view>
				<view class="tj-item">
					<text class="num"
						@click="navTo('/pagesA/sys/user/point-list')">{{userInfo.integration||0}}</text>
					<text>积分</text>
				</view>
				<view class="tj-item" @click="navTo('/pagesA/sys/user/performance')">
					<text class="num">{{ monthOrderNum }}</text>
					<text>本月订单</text>
				</view>
				<view class="tj-item" @click="navTo('/pagesB/coupon/user/coupon')">
					<text class="num">{{couponCount||0}}</text>
					<text>优惠券</text>
				</view>
			</view> -->
			<!-- 订单 -->
			<!-- <view class="order-section">
				<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=')" hover-class="common-hover"
					:hover-stay-time="50">
					<text class="yticon icon-shouye"></text>
					<text>全部订单</text>
				</view>
				<view  class="order-item" @click="navTo('/pagesA/appointment/service/orderList?type=')"
					hover-class="common-hover" :hover-stay-time="50">
					<text class="yticon icon-shouye"></text>
					<text>预约服务</text>
				</view>
				<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=0')" hover-class="common-hover"
					:hover-stay-time="50">
					<text class="yticon icon-daifukuan"></text>
					<text>待付款</text>
					<uni-badge type="error" v-if="toPayOrderCount>0" :text="toPayOrderCount+''"></uni-badge>
				</view>
				<view class="order-item" @click="navTo('/pagesA/sys/user/order?type=2')" hover-class="common-hover"
					:hover-stay-time="50">
					<text class="yticon icon-yishouhuo"></text>
					<text>待收货</text>
					<uni-badge type="error" v-if="toConfirmOrderCount>0" :text="toConfirmOrderCount+''"></uni-badge>
				</view>
				<view class="order-item" @click="navTo('/pagesA/sys/user/aftersale')" hover-class="common-hover"
					:hover-stay-time="50">
					<text class="yticon icon-shouhoutuikuan"></text>
					<text>退款/售后</text>
					<uni-badge type="error" v-if="afterSaleCount>0" :text="afterSaleCount+''"></uni-badge>
				</view>
			</view> -->
			<!-- </view> -->
			<!-- 今日订单模块 -->
			<view class="today-order-box" v-if="showShopStatus">
				<!-- 说明 -->
				<view class="taitl-today-text">
					<view class="today-body-text">
						<span style="margin-right: 5rpx;">今日订单</span>
						<u-icon size="40" name="eye" @click="showMoneyStatus = !showMoneyStatus"></u-icon>
					</view>
					<view style="font-size: 28rpx;" >
						<picker mode="date" :value="dayDateNum" :end="endDate" @change="bindDateChange">
							<u-icon name="calendar-fill" style="margin-right: 5rpx;"></u-icon> 
							<span>{{dayDateNum}}</span> 
						</picker>
					</view>
				</view>
				<!-- 显示详情 -->
				<view class="u-demo-block__content">
					<u-row justify="space-between" gutter="10">
						<u-col span="4">
							<view class="demo-layout bg-purple" >
								<view class="numberMartet">
									<view  style="margin-top: 20rpx; font-size: 32rpx; font-weight: 500; color: red;">
										￥{{ showMoneyStatus == true?(dayMap.amount == null?'0.00':dayMap.amount):'***'}}
									</view>
									<view class="">
										经营收益
									</view>
								</view>
							</view>
						</u-col>
						<u-col span="4">
							<view class="demo-layout bg-purple-light" @click="goDayDataPage">
								<view class="numberMartet">
									<view  style="margin-top: 20rpx; font-size: 32rpx; font-weight: 500;">
										{{ showMoneyStatus == true?(dayMap.orderNum == null?0:dayMap.orderNum):'***' }}
									</view>
									<view class="">
										订单数
									</view>
								</view>
							</view>
						</u-col>
						<u-col v-if="false" span="4">
							<view class="demo-layout bg-purple-light"  @click="openScan">
								<view class="numberMartet">
									<u-icon name="grid" size="38" style="margin-top: 30rpx;"></u-icon>
									<view class="">
										核销服务
									</view>
								</view>
							</view>
						</u-col>
						<u-col v-if="false" span="4">
							<view class="demo-layout bg-purple-light" @click="goAwaitOrderPage">
								<view class="numberMartet">
									<u-icon name="order" size="38" style="margin-top: 30rpx;"></u-icon>
									<view class="">
										待核销订单
									</view>
								</view>
							</view>
						</u-col>
						<u-col span="4" v-if="false">
							<view class="demo-layout bg-purple-light"  @click="goTaskDispatchPage">
								<view class="numberMartet">
									<u-icon name="man-add-fill" size="38" style="margin-top: 30rpx;"></u-icon>
									<view class="">
										任务委派
									</view>
								</view>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			
			<view class="other-server">
				<view class="server-title">我的服务</view>
				<view class="server-list">
					<view v-if="isShopSys" class="server-cell" hover-class="none-hover" @click="navTo('/pagesB/shop/management/shopList')">
						<image src="https://yuyitang.oss-cn-shenzhen.aliyuncs.com/yytfile/upload/2022/07/30/ad7914b3-63e9-46bf-ba2d-115c3474eee1.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">店铺管理</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</view>
					<navigator class="server-cell" hover-class="none-hover" url="/pagesB/vip/topUp/interests">
						<image src="../../../static/image/mine/server-01.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">会员权益</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</navigator>
					<view class="server-cell" hover-class="none-hover" @click="navTo('/pagesB/coupon/user/coupon')">
						<image src="../../../static/image/mine/server-02.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">优惠券</view>
							<view v-if="couponCount > 0" class="number-coupon">
								{{couponCount}}
							</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</view>
					<view class="server-cell" hover-class="none-hover" @click="navTo('/pagesA/sys/user/product')">
						<image src="../../../static/image/mine/server-03.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">我的收藏</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</view>
					<view class="server-cell" hover-class="none-hover" @click="navTo('/pages/sys/shopCart/address')">
						<image src="../../../static/image/mine/server-04.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">我的地址</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</view>
					<view class="server-cell" hover-class="none-hover" @click="navTo('/pagesA/sys/user/set')">
						<image src="../../../static/image/mine/server-05.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">个人信息</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</view>
					<view class="server-cell" hover-class="none-hover" @click="customerService">
						<image src="../../../static/image/mine/server-06.png" mode="aspectFit" class="icon"></image>
						<view class="server-data">
							<view class="server-tips">客服售后</view>
							<image src="../../../static/image/small-arrow.png" mode="aspectFit" class="arrow"></image>
						</view>
					</view>
				</view>
			</view>
			<!-- 浏览历史 -->
			<view class="history-section icon" v-if="footPrint.length>0">
				<view class="sec-header">
					<text class="yticon icon-lishijilu"></text>
					<text>浏览历史</text>
				</view>
				<scroll-view scroll-x class="h-list">
					<image @click="navTo('/pages/product/product?id='+footPrint[footPrint.length-index-1].productUuid)"
						:src="footPrint[footPrint.length-index-1].productMainImage.url" mode="aspectFill"
						v-for="(product,index) in footPrint"></image>
				</scroll-view>
				<!-- <list-cell icon="icon-tuan" iconColor="#e07472" title="我的拼团" @eventClick="navTo('/pagesA/sys/user/groupbuy')"></list-cell> -->
				<!-- <list-cell icon="icon-point" iconColor="#F8BD9F" title="兑换记录" @eventClick="navTo('/pagesA/sys/user/point')"></list-cell> -->
				<!-- <list-cell icon="icon-tuandui" iconColor="#FF8C00" title="扫描二维码" @eventClick="openScan"></list-cell> -->
				<!-- <list-cell v-if="isShopSys" icon="icon-shouye" iconColor="#FFBB66" title="店铺管理"
					@eventClick="navTo('/pagesB/shop/management/shopList')"></list-cell>
				<list-cell icon="icon-shouhuodizhi" iconColor="#5fcda2" title="地址管理"
					@eventClick="navTo('/pages/sys/shopCart/address')"></list-cell>
				<list-cell icon="icon-shoucang_xuanzhongzhuangtai" iconColor="#54b4ef" title="我的收藏"
					@eventClick="navTo('/pagesA/sys/user/product')"></list-cell> -->
				<!--				<list-cell icon="icon-xiaoxi" iconColor="#DB3F60" title="消息中心" border="" @eventClick="navTo('/pagesA/sys/user/notice')"></list-cell>-->
				<!-- <list-cell icon="icon-shezhi" iconColor="#7EAFA5" title="设置" border=""
					@eventClick="navTo('/pagesA/sys/user/set')"></list-cell> -->
			</view>
		</view>
		
		
	</view>
</template>
<script>
	import listCell from '@/components/mix-list-cell';
	import uniBadge from "@/components/uni-badge/uni-badge.vue";
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	// #ifdef H5
	import shareByH5 from '@/components/share/shareByh5.vue'
	// #endif
	// #ifdef MP-WEIXIN
	import shareByWx from '@/components/share/shareByWx.vue'
	// #endif
	// #ifdef MP-ALIPAY
	import shareByAli from '@/components/share/shareByAli.vue'
	// #endif
	// #ifdef APP-PLUS
	import shareByApp from '@/components/share/shareByApp.vue'
	// #endif
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		getMineOrderCount
	} from "../../../config/api";
	let startY = 0,
		moveY = 0,
		pageAtTop = true;
	export default {
		components: {
			listCell,
			uniBadge,
			uniPopup,
			// #ifdef H5
			shareByH5,
			// #endif

			// #ifdef MP-WEIXIN
			shareByWx,
			// #endif

			// #ifdef MP-ALIPAY
			shareByAli,
			// #endif

			// #ifdef APP-PLUS
			shareByApp,
			// #endif
		},
		data() {
			return {
				// 会员类型
				myVipInfo: null,
				// 可送次数
				myNumber: 0,
				// 等级经验值
				empirical: {},
				// 是否同意账号迁移
				authChange: true,
				// 日期
				endDate: '',
				dayDateNum: '',
				// 今日订单数据
				dayMap: {},
				// 是否显示店铺管理
				showShopStatus: false,
				//是否是店铺管理员
				isShopSys: false,
				// 显示隐藏金额
				showMoneyStatus: true,
				type: '',
				coverTransform: 'translateY(0px)',
				coverTransition: '0s',
				moving: false,
				toPayOrderCount: 0,
				toConfirmOrderCount: 0,
				afterSaleCount: 0,
				isphone: false,
				phone: "",
				monthOrderNum: 0,
				dayOrderNum: 0,
				couponCount: 0,
				rebate: 0,
				plan: 0,
				safeArea: {}
			}
		},
		onLoad() {			
			this.getMyList()
			this.dayDateNum = new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
			this.endDate = new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
		},
		onShow() {
			let token = uni.getStorageSync('userToken')
			if (token.length != 0) {
				this.$api.request.userInfo({
					type: 'application/x-www-form-urlencoded',
				}, res => {
					// console.log(res);
					if (res.code == 200) {						
						this.login(res.data)
						uni.setStorageSync('userInfo', res.data)
					}
				})
			}
			this.getMyNumber()
			this.getMyList()
			this.getMySysShopList()
			this.getOrderCount();
			this.getMyCouponCount()
			this.getMyRebate()
			this.getMyIsVip()
			this.getUserEmpirical()
			if (uni.getStorageSync('authStatus') == false) {
				uni.removeTabBarBadge({
					index: 2
				})
				this.monthOrderNum = 0
				this.couponCount = 0
				this.rebate = 0
			} else {
				this.getShopCart()				
			}
			this.safeArea = uni.getSystemInfoSync().safeArea
		},
		computed: {
			...mapState(['hasLogin', 'userInfo', 'footPrint', 'applicationConfig', 'token', 'session_key', 'openid']),
			shareHref() {
				let pages = getCurrentPages()
				let page = pages[pages.length - 1]
				// #ifdef H5 || MP-WEIXIN || APP-PLUS || APP-PLUS-NVUE
				return this.$api.request.apiBaseUrl.replace("/b2b2c/rest/", "") + '/#/pages/public/register?id=' + this
					.userInfo
					.userUuid;
				// #endif

				// #ifdef MP-ALIPAY
				return this.$api.request.apiBaseUrl.replace("/b2b2c/rest/", "") + '/#/pages/public/register?id=' + this
					.userInfo
					.userUuid;
				// #endif
			}
		},
		methods: {
			...mapMutations(['login']),
			async wxLogin() {
				if (this.openid == null) {
					uni.login({
						success: (res) => {
							// console.log(res);
							this.$api.request.getOpenid({
								code: res.code
							}, res => {
								// console.log(res);
								if (res.code == 200) {
									let data = JSON.parse(res.data)
									this.$store.commit("setOpenId", data)
									// console.log(data.openid);
								}
							})
						}
					})
				}
				await this.$api.request.getWxUser({
					wechatId: this.openid
				}, res => {
					if (res.code == 200 && res.data != 404) {
						this.$u.toast("微信登陆成功！", 4000)
						this.$store.commit("setToken", res.data.tokenValue)
						this.$store.commit("login", res.data);
						setTimeout(res => {
							uni.switchTab({
								url: "/pages/sys/home/index"
							})
						}, 1000)
					}

				})
			},
			/** 查看会员详情 */
			goVipRenew(){
				uni.navigateTo({
					url: '/pagesB/vip/topUp/mine'
				})
			},
			/** 获取当前用户是否是会员 */
			getMyIsVip(){
				this.$api.request.getMyVipInfo({
					memberId: uni.getStorageSync('userInfo').id
				}, res => {
					if(res.code == 200){
						this.myVipInfo = res.data || null
					}
				})
			},
			bindDateChange: function(e) {
				this.dayDateNum = e.detail.value
				this.$api.request.getDayCountNumber({
					dayDate: e.detail.value
				}, response => {
					if(response.code == 200){
						this.dayMap = response.data
					}
				})
			},
			toggleSignPoint: function() {
				uni.navigateTo({
					url: '/pages/point/sign'
				})
			},
			addphoneBtn() {
				if (!this.$api.util.validateMobileNo(this.phone)) {
					this.$api.msg('手机号码格式错误');
				} else {
					this.$api.request.setPhone({
						phone: this.phone,
						id: this.userInfo.id
					}, res => {
						this.$api.msg("修改成功")
						uni.setStorageSync("isphone", true)
						this.$store.state.userInfo.phone = this.phone
						setTimeout(res => {
							this.isphone = false
						}, 500)
					})
				}

			},
			getShopCart() {
				this.$api.request.getShopCart({}, res => {
					// this.cartList=res.data
					if (res.data.length > 0) {
						uni.setTabBarBadge({
							index: 2,
							text: res.data.length.toString()
						})
					} else {
						uni.removeTabBarBadge({
							index: 2
						})
					}
				})
			},			
			getphone(e) {
				if (typeof(e.detail.iv) != "undefined") {
					let userInfo = uni.getStorageSync("userInfo")
					this.$api.request.getPhone({
						id: userInfo.id,
						encryptedData: e.detail.encryptedData,
						iv: e.detail.iv,
						sessionKey: this.session_key,
						sourceType: "APP",
						f: 2
					}, res => {
						// console.log(res);
						if (res.code == 200) {
							uni.setStorageSync("isphone", true)
							this.isphone = false
							this.phone = res.data
							setTimeout(res => {
								this.wxLogin()
							}, 1000)
						}

					})

				} else {
					this.$u.toast("未获取手机号")
				}

			},
			// 查看更多今日数据
			goDayDataPage(){
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/sys/common/login'
					})
				// 	const that = this
				// 	uni.getUserProfile({
				// 		desc: "获取你的昵称、头像、地区及性别",
				// 		success: (res) => {
				// 			console.log(res);
				// 			uni.showLoading({
				// 				//title: '加载中'
				// 			});
				// 			this.$api.request.userLoginOrAdd({
				// 				encryptedData: res.encryptedData,
				// 				iv: res.iv,
				// 				sessionKey: this.session_key,
				// 				wechatId: uni.getStorageSync('openId'),
				// 				sourceType: "APP",
				// 				nickName: res.userInfo.nickName,
				// 				avatarUrl: res.userInfo.avatarUrl
				// 			}, resp => {
				// 				console.log(resp);
				// 				uni.hideLoading();
				// 				if (resp.code == 200) {
				// 					this.$store.commit("setToken", resp.data.tokenValue)
				// 					this.$store.commit("login", resp.data);
				// 					uni.setStorageSync('authStatus', true)
				// 					this.$api.request.userInfo({}, res => {
				// 						if (res.code == 200) {
				// 							uni.setStorageSync('userInfo', res.data)
				// 							setTimeout(() => {
				// 								uni.navigateTo({
				// 									url: '/pagesB/shop/dayOrder/orderList?dayDate='+this.dayDateNum
				// 								})
				// 							}, 500)
				
				// 						}
				// 					})
				
				// 				}
				// 			})
				// 		}
				// 	})
				} else {
					uni.navigateTo({
						url: '/pagesB/shop/dayOrder/orderList?dayDate='+this.dayDateNum
					})
				}
			},
			// 点击进入任务委派页面
			goTaskDispatchPage(){
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/sys/common/login'
					})
				// 	const that = this
				// 	uni.getUserProfile({
				// 		desc: "获取你的昵称、头像、地区及性别",
				// 		success: (res) => {
				// 			console.log(res);
				// 			uni.showLoading({
				// 				//title: '加载中'
				// 			});
				// 			this.$api.request.userLoginOrAdd({
				// 				encryptedData: res.encryptedData,
				// 				iv: res.iv,
				// 				sessionKey: this.session_key,
				// 				wechatId: uni.getStorageSync('openId'),
				// 				sourceType: "APP",
				// 				nickName: res.userInfo.nickName,
				// 				avatarUrl: res.userInfo.avatarUrl
				// 			}, resp => {
				// 				console.log(resp);
				// 				uni.hideLoading();
				// 				if (resp.code == 200) {
				// 					this.$store.commit("setToken", resp.data.tokenValue)
				// 					this.$store.commit("login", resp.data);
				// 					uni.setStorageSync('authStatus', true)
				// 					this.$api.request.userInfo({}, res => {
				// 						if (res.code == 200) {
				// 							uni.setStorageSync('userInfo', res.data)
				// 							this.getShopCart()
				// 							this.login(res.data)
				// 							this.getMyList()
				// 							this.getMySysShopList()
				// 							this.getOrderCount();
				// 							this.getMyCouponCount()
				// 							this.getMyRebate()
				// 							this.getUserEmpirical()
				// 							uni.navigateTo({
				// 								url: '/pagesB/order/task/dispatch'
				// 							})
				// 						}
				// 					})
				
				// 				}
				// 			})
				// 		}
				// 	})
				} else {
					uni.navigateTo({
						url: '/pagesB/order/task/dispatch'
					})
				}
				
			},
			// 点击进入待核销订单页面
			goAwaitOrderPage(){
				uni.navigateTo({
					url: '/pagesB/order/await/cancel'
				})
			},
			// 获取待付款和待收货数量 本月订单数量
			getOrderCount() {
				if (uni.getStorageSync('authStatus') == true) {
					this.$api.request.getMineOrderCount(res => {
						this.toPayOrderCount = res.data.unPayCount;
						this.toConfirmOrderCount = res.data.waitReceiveCount;
					});
					this.$api.request.countMonthOrder(res => this.monthOrderNum = res.data);
				}
			},
			getMyCouponCount(){
				if(uni.getStorageSync('authStatus') == true){
					this.$api.request.getMyCouponList({
						memberId: uni.getStorageSync('userInfo').id,
						useType: 0
					}, res => {
						if(res.code == 200){
							this.couponCount = res.data.length
						}
					})
				}
			},
			getMyNumber(){
				if(uni.getStorageSync('authStatus') == true){
					this.$api.request.getMyNumber({
						memberId: uni.getStorageSync('userInfo').id
					}, res => {
						if(res.code == 200){
							console.log(res.data);
							if(res.data == null){
								this.myNumber = 0
							}else {
								this.myNumber = res.data.greensNumber
							}
						}
					})
				}
				
			},
			getMyRebate(){
				if(uni.getStorageSync('authStatus') == true){
					this.$api.request.getMyRebate({
						memberId: uni.getStorageSync('userInfo').id,
					}, res => {
						if(res.code == 200){
							this.rebate = res.data.rebate
						}
					})
				}
			},
			getUserEmpirical(){
				if(uni.getStorageSync('authStatus') == true){
					this.$api.request.getUserEmpirical({
						memberId: uni.getStorageSync('userInfo').id,
					}, res => {
						if(res.code == 200){
							this.empirical = res.data
							this.plan = (uni.getStorageSync('userInfo').growth / res.data.growthPointEnd * 100).toFixed(0)
						}
					})
				}
			},
			togglePopup(type, open) {
				switch (type) {
					case 'top':
						this.content = '顶部弹出 popup'
						break

					case 'bottom':
						this.content = '底部弹出 popup'
						break
					case 'center':
						this.content = '居中弹出 popup'
						break
				}
				this.type = type
				this.$nextTick(() => {
					this.$refs['show' + open].open()
				})
			},
			closeShare() {
				this.$refs.showshare.close();
			},
			inquiryAfterSaleTotal(statusList) {
				var keyArray = ['USER'];
				let searchOptions = {
					userUuid: this.userInfo.userUuid
				};
				if (statusList && statusList.length > 0) {
					keyArray.push('STATUS_LIST');
					searchOptions.statusList = statusList;
				}
				searchOptions.keyArray = keyArray;
				this.$api.request.searchAfterSaleTotal(searchOptions, res => {
					if (res.body.status.statusCode === '0') {
						var afterSaleCount = res.body.data.total;
						this.afterSaleCount = afterSaleCount;
					} else {
						console.log(res.body.status.errorDesc);
					}
				}, true);
			},
			immediatelyLogin() {
				// const that = this
				// uni.getUserProfile({
				// 	desc: "获取你的昵称、头像、地区及性别",
				// 	success: (res) => {
				// 		console.log(res);
				// 		uni.showLoading({
				// 			//title: '加载中'
				// 		});
				// 		this.$api.request.userLoginOrAdd({
				// 			encryptedData: res.encryptedData,
				// 			iv: res.iv,
				// 			sessionKey: this.session_key,
				// 			wechatId: uni.getStorageSync('openId'),
				// 			sourceType: "APP",
				// 			nickName: res.userInfo.nickName,
				// 			avatarUrl: res.userInfo.avatarUrl
				// 		}, resp => {
				// 			console.log(resp);
				// 			uni.hideLoading();
				// 			if (resp.code == 200) {
				// 				this.$store.commit("setToken", resp.data.tokenValue)
				// 				this.$store.commit("login", resp.data);
				// 				uni.setStorageSync('authStatus', true)
				// 				this.$api.request.userInfo({}, res => {
				// 					if (res.code == 200) {
				// 						uni.setStorageSync('userInfo', res.data)
				// 						this.getShopCart()
				// 						this.login(res.data)
				// 						this.getMyList()
				// 						this.getMySysShopList()
				// 						this.getOrderCount();
				// 						this.getMyCouponCount()
				// 					}
				// 				})

				// 			}
				// 		})
				// 	}
				// })
				uni.navigateTo({
					url: '/pages/sys/common/login'
				})
			},
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			navTo(url) {
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/sys/common/login'
					})
					// const that = this
					// uni.getUserProfile({
					// 	desc: "获取你的昵称、头像、地区及性别",
					// 	success: (res) => {
					// 		console.log(res);
					// 		uni.showLoading({
					// 			//title: '加载中'
					// 		});
					// 		this.$api.request.userLoginOrAdd({
					// 			encryptedData: res.encryptedData,
					// 			iv: res.iv,
					// 			sessionKey: this.session_key,
					// 			wechatId: uni.getStorageSync('openId'),
					// 			sourceType: "APP",
					// 			nickName: res.userInfo.nickName,
					// 			avatarUrl: res.userInfo.avatarUrl
					// 		}, resp => {
					// 			console.log(resp);
					// 			uni.hideLoading();
					// 			if (resp.code == 200) {
					// 				this.$store.commit("setToken", resp.data.tokenValue)
					// 				this.$store.commit("login", resp.data);
					// 				uni.setStorageSync('authStatus', true)
					// 				this.$api.request.userInfo({}, res => {
					// 					if (res.code == 200) {
					// 						uni.setStorageSync('userInfo', res.data)
					// 						setTimeout(() => {
					// 							uni.navigateTo({
					// 								url
					// 							})
					// 						}, 500)

					// 					}
					// 				})

					// 			}
					// 		})
					// 	}
					// })
				} else {
					uni.navigateTo({
						url
					})
				}
			},
			customerService() {
				uni.navigateTo({
					url: '/pages/sys/help/help'
				})
			},
			/**
			 *  会员卡下拉和回弹
			 *  1.关闭bounce避免ios端下拉冲突
			 *  2.由于touchmove事件的缺陷（以前做小程序就遇到，比如20跳到40，h5反而好很多），下拉的时候会有掉帧的感觉
			 *    transition设置0.1秒延迟，让css来过渡这段空窗期
			 *  3.回弹效果可修改曲线值来调整效果，推荐一个好用的bezier生成工具 http://cubic-bezier.com/
			 */
			coverTouchstart(e) {
				if (pageAtTop === false) {
					return;
				}
				this.coverTransition = 'transform .1s linear';
				startY = e.touches[0].clientY;
			},
			coverTouchmove(e) {
				moveY = e.touches[0].clientY;
				let moveDistance = moveY - startY;
				if (moveDistance < 0) {
					this.moving = false;
					return;
				}
				this.moving = true;
				if (moveDistance >= 80 && moveDistance < 100) {
					moveDistance = 80;
				}

				if (moveDistance > 0 && moveDistance <= 80) {
					this.coverTransform = `translateY(${moveDistance}px)`;
				}
			},
			coverTouchend() {
				if (this.moving === false) {
					return;
				}
				this.moving = false;
				this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
				this.coverTransform = 'translateY(0px)';
			},
			openScan() {
				const that = this
				if (!this.hasLogin) {
					uni.navigateTo({
						url: '/pages/sys/common/login'
					})
				// 	const that = this
				// 	uni.getUserProfile({
				// 		desc: "获取你的昵称、头像、地区及性别",
				// 		success: (res) => {
				// 			console.log(res);
				// 			uni.showLoading({
				// 				//title: '加载中'
				// 			});
				// 			this.$api.request.userLoginOrAdd({
				// 				encryptedData: res.encryptedData,
				// 				iv: res.iv,
				// 				sessionKey: this.session_key,
				// 				wechatId: uni.getStorageSync('openId'),
				// 				sourceType: "APP",
				// 				nickName: res.userInfo.nickName,
				// 				avatarUrl: res.userInfo.avatarUrl
				// 			}, resp => {
				// 				console.log(resp);
				// 				uni.hideLoading();
				// 				if (resp.code == 200) {
				// 					this.$store.commit("setToken", resp.data.tokenValue)
				// 					this.$store.commit("login", resp.data);
				// 					uni.setStorageSync('authStatus', true)
				// 					this.$api.request.userInfo({}, res => {
				// 						if (res.code == 200) {
				// 							uni.setStorageSync('userInfo', res.data)
				// 							this.getShopCart()
				// 							this.login(res.data)
				// 							this.getMyList()
				// 							this.getMySysShopList()
				// 							this.getOrderCount();
				// 							this.getMyCouponCount()
				// 							this.getMyRebate()
				// 							this.getUserEmpirical()
				// 						}
				// 					})
				
				// 				}
				// 			})
				// 		}
				// 	})
				} else{
					uni.scanCode({
						onlyFromCamera: true,
						scanType: ['barCode', 'qrCode', 'datamatrix'],
						success: res => {
							console.log(res);
							console.log('条码类型：' + res.scanType);
							console.log('条码内容：' + res.result);
							console.log('条码内容：' + res.code);
							console.log('条码内容：' + res.qrCode);
							uni.showModal({
								title: '核销服务',
								content: '是否核销此订单？\n 订单号：' + res.result,
								success: resp => {
									if (resp.confirm) {
										that.$api.request.getWeChatInfo({
											wechatId: uni.getStorageSync('openId'),
											orderId: res.result
										}, isAuth => {
											if(isAuth.code == 200){
												if(isAuth.data.length > 0){
													console.log('确认核销');
													that.$api.request.updateOrderService({
														orderId: res.result
													}, result => {
														if(result.code == 200){
															if(result.data == true){
																setTimeout(() => {
																	uni.showToast({
																		title: '核销成功',
																		icon: 'success',
																	})
																}, 200)
															}else{
																setTimeout(() => {
																	uni.showToast({
																		title: '该订单已核销',
																		icon: 'success',
																	})
																},200)
															}
															
														}
													})
												}else{
													uni.showModal({
														title: '温馨提示',
														content: '权限不足，委派的手艺人方可核销',
														showCancel: false,
														success() {
															
														}
													})
												}
											}
										})
										
										
									} else if (resp.cancel) {
										console.log('取消核销');
									}
								}
							})
						}
					})
				}				
			},
			// 获取我是管理员的店铺列表
			getMySysShopList(){
				try{
					this.$api.request.getMySysShopList({
						wechatId: uni.getStorageSync('userInfo').id
					}, res => {
						if(res.code == 200){
							this.isShopSys = res.data.length > 0?true:false
						}
					})
				}catch(err){
					console.log(err);
				}
				
			},
			// 获取我的店铺列表
			getMyList() {
				const that = this
				that.$api.request.myShopList({
					wechatId: uni.getStorageSync('userInfo').id
				}, res => {
					console.log(res);
					if (res.code == 200) {
						that.showShopStatus = res.data.length > 0 ? true : false
						if(res.data.length > 0){
							that.$api.request.getDayCountNumber({
								dayDate: new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
							}, response => {
								if(response.code == 200){
									that.dayMap = response.data
									that.dayDateNum = new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
								}
							})
						}
					}
				})
			},
		}
	}
</script>
<style lang='scss' scoped>
	.container{
		min-height: 100vh;
		background: $page-gery-light;
	}
	%flex-center {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	%section {
		display: flex;
		justify-content: space-around;
		align-content: center;
		background: #fff;
		border-radius: 10upx;
	}

	.sign-point {
		position: absolute;
		right: 100rpx;
		text-align: center;
		color: #fff;
	}

	.sign-point-text {
		font-size: 22rpx;
		margin-top: 4rpx;
	}

	.sign-point .iconfont {
		color: #fff;
		background: rgba(0, 0, 0, 0.1);
		width: 72rpx;
		height: 72rpx;
		text-align: center;
		line-height: 72rpx;
		border-radius: 50%;
		display: inline-block;
	}

	.customer-service {
		position: absolute;
		right: 0rpx;
		text-align: center;
		color: #fff;
	}

	.customer-service-text {
		font-size: 22rpx;
		margin-top: 4rpx;
	}

	.customer-service .iconfont {
		color: #fff;
		background: rgba(0, 0, 0, 0.1);
		width: 72rpx;
		height: 72rpx;
		text-align: center;
		line-height: 72rpx;
		border-radius: 50%;
		display: inline-block;
	}

	.user-section {
		padding: 0 38rpx 110rpx;
		position: relative;
		.bg {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 408rpx;
			background: linear-gradient(360deg, #F7F8FA 0%, #F7F7F7 0%, #E9FFF8 40%, #C7FFEC 100%);;
			/* filter: blur(1px); */
			/* opacity: .7; */
		}
		.bg-img{
			position: absolute;
			top: 0;
			right: 0;
			z-index: 1;
			width: 432rpx;
			height: 210rpx;
		}
	}

	.user-info-box {
		display: flex;
		align-items: center;
		position: relative;
		z-index: 1;
		.portrait {
			width: 120rpx;
			height: 120rpx;
			border: 4rpx solid #fff;
			border-radius: 50%;
			box-shadow: 0px 16px 20px 0px rgba(6,147,19,0.2200);
		}

		.username {
			font-size: $font-sm;
			color: $font-color-base;
			margin-left: 20upx;
		}
		.user-right{
			display: flex;
			justify-content: center;
			align-items: flex-start;
			flex-direction: column;
			margin-left: 24rpx;
		}
		.user-name{
			color: #111111; 
			font-size: 34rpx; 
			font-weight: medium;
		}
		.user-other{
			display: flex;
			align-items: center;
			margin-top: 10rpx;
			.phone{
				font-size: 26rpx;
				color: #333;
			}
			.vip-label{
				display: flex;
				align-items: center;
				margin-left: 16rpx;
				border-radius: 18rpx;
				background: rgba(0, 155, 101,.1);
				padding: 6rpx 18rpx 6rpx 10rpx;
				.icon{
					width: 28rpx;
					height: 24rpx;
					margin-right: 4rpx;
				}
				.label{
					font-size: 24rpx;
					color: #009B65;
				}
			}
		}
	}
	
	.user-grade {
		text-align: center;
		/* width: 140rpx; */
		height: 30rpx;
		padding: 0rpx 20rpx;
		background: #f5cb54;
		border-radius: 20rpx;
		color: #9e760d;
		font-size: 18rpx;
		display: flex;
		flex-direction: row;
	}

	.login-box {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 20rpx;
		.b-btn {
			height: 40upx;
			text-align: center;
			line-height: 40upx;
			font-size: 22upx;
			color: #36343c;
			border-radius: 8rpx;
			background: linear-gradient(to left, #f9e6af, #ffd465);
			padding: 0 20upx;
		}
	}

	.cover-container {
		padding: 0 20upx;
		position: relative;
		padding-bottom: 20upx;
		margin-top: -50rpx;
		/* .arc {
			position: absolute;
			left: 0;
			top: -34upx;
			width: 100%;
			height: 36upx;
		} */
		.vip-box{
			background-color: #C9A984;
			border-radius: 24rpx 24rpx 0 0;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-right: 24rpx;
			margin: 0 20rpx;
			.icon{
				width: 76rpx;
				height: 64rpx;
			}
			.vip-tips{
				flex: 1;
				overflow: hidden;
				font-size: 26rpx;
				color: #F8EDD8;
				font-family: '仓耳渔阳体 W05';
			}
			.btn{
				background: linear-gradient(270deg, #D9B28F 0%, #966F43 100%);
				box-shadow: inset 0px 2rpx 6rpx 0px #E6B98D;
				border-radius: 26rpx;
				display: flex;
				align-items: center;
				padding: 6rpx 12rpx 6rpx 26rpx;
				.tips{
					font-size: 22rpx;
					color: #fff;
					margin-right: 10rpx;
				}
			}
		}
	}

	.tj-sction {
		@extend %section;
		align-items: baseline;

		.tj-item {
			@extend %flex-center;
			flex-direction: column;
			height: 140upx;
			font-size: $font-sm;
			color: #75787d;

			.b-btn {
				margin: 10px 0;
				width: 132upx;
				height: 40upx;
				text-align: center;
				line-height: 40upx;
				font-size: 22upx;
				color: #fff;
				border-radius: 10px;
				background: linear-gradient(left, #f5cb54, #9e760d);
				z-index: 1;
			}
		}

		.num {
			font-size: $font-lg;
			color: $font-color-dark;
			margin-bottom: 8upx;
		}
	}

	.order-section {
		/* @extend %section; */
		padding: 32rpx 20rpx 32rpx 40rpx;
		background: #fff;
		border-radius: 16rpx;
		box-shadow: 0px 4px 20px 0px rgba(0,0,0,0.0400);
		margin-bottom: 24rpx;
		.order-title{
			display: flex;
			justify-content: space-between;
			align-items: center;
			.title{
				font-size: 32rpx;
				color: #111;
			}
			.order-arrow{
				display: flex;
				justify-content: flex-end;
				align-items: center;
				font-size: 28rpx;
				color: #999;
				.arrow{
					width: 24rpx;
					height: 24rpx;
					margin-left: 10rpx;
				}
			}
		}
		/* .order-item {
			position: relative;
			@extend %flex-center;
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
			font-size: $font-sm;
			color: $font-color-dark;
		} */
		.order-list{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 42rpx;
			padding-right: 20rpx;
			.order-item{
				position: relative;
				
				.order-icon{
					width: 80rpx;
					height: 80rpx;
					display: block;
					margin: auto;
				}
				.order-title{
					font-size: 28rpx;
					margin-top: 16rpx;
					color: #111;
					text-align: center;
				}
			}
		}
		.yticon {
			font-size: 48upx;
			margin-bottom: 18upx;
			color: #7EAFA5;
		}

		.icon-shouhoutuikuan {
			font-size: 44upx;
		}

		.uni-badge {
			position: absolute;
			top: -2px;
			left: 30px;
			background: #dd524d;
			color: #fff;
		}
	}

	.history-section {
		padding: 30upx 0 0;
		background: #fff;
		border-radius: 10upx;

		.sec-header {
			display: flex;
			align-items: center;
			font-size: $font-base;
			color: $font-color-dark;
			line-height: 40upx;
			margin-left: 30upx;

			.yticon {
				font-size: 44upx;
				color: #5eba8f;
				margin-right: 16upx;
				line-height: 40upx;
			}
		}

		.h-list {
			white-space: nowrap;
			padding: 30upx 30upx 0;

			image {
				display: inline-block;
				width: 160upx;
				height: 160upx;
				margin-right: 20upx;
				border-radius: 10upx;
			}
		}
	}

	.nearby {
		opacity: .5;
		background-color: #000;
		position: absolute;
		right: 0px;
		top: 150upx;
		width: 200upx;
		height: 60upx;
		line-height: 60upx;
		z-index: 999;
		color: #fff;
		font-size: $font-base;
		border-radius: 100upx 0px 0px 100upx;
		text-align: center;
	}

	.today-order-box {
		width: auto;
		background: #FFFFFF;
		margin: 10rpx 0;
		padding: 10rpx 30rpx;
		border-radius: 20rpx;

		.taitl-today-text {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;

			.today-body-text {
				font-size: 32rpx;
				font-weight: 500;
				color: #000000;
			}
		}

		
	}
	
	.numberMartet {
		width: 100%;
		height: 120rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		/* border: 1rpx solid #07BB07; */
	}
	

	.wrap {
		padding: 12px;
	}
	
	.other-server{
		background: #fff;
		border-radius: 16rpx;
		box-shadow: 0px 4px 20px 0px rgba(0,0,0,0.0400);
		padding: 32rpx 40rpx;
		.server-title{
			font-size: 32rpx;
			color: #111;
			padding-bottom: 14rpx;
		}
		.server-list{
			.server-cell{
				display: flex;
				align-items: flex-start;
				padding-top: 28rpx;
				.icon{
					width: 40rpx;
					height: 40rpx;
					margin-right: 24rpx;
				}
				.server-data{
					position: relative;
					flex: 1;
					overflow: hidden;
					padding-bottom: 26rpx;
					border-bottom: 1rpx solid #EBECF0;
					display: flex;
					justify-content: space-between;
					align-items: center;
					.server-tips{
						font-size: 26rpx;
						color: #111;
					}
					.arrow{
						width: 24rpx;
						height: 24rpx;
					}
				}
			}
		}
	}
	
	.number-coupon{
		width: 30rpx;
		height: 30rpx;
		line-height: 30rpx;
		background: red;
		border-radius: 30rpx;
		color: #F7F7F7;
		text-align: center;
		position: absolute;
		top: 0;
		left: 90rpx;
	}

</style>
